/*
 *  SingleGroupGeneratorTester.cpp
 *  SoundController0002
 *
 *  Created by jiro on 11/07/17.
 *  Copyright 2011 jiro music. All rights reserved.
 *
 */

#include "Theory0039_SingleGroupGeneratorTester.h"
#include "../Theory0039_SingleGroupGenerator.h"
#include "../../../sc/Tester/CustomAssert.h"

namespace theory0039 {

	void SingleGroupGeneratorTester::TestAll()
	{
		Test_GetDegree();
		Test_GenerateChord();
	}

	void SingleGroupGeneratorTester::Test_GenerateChord()
	{
		{
			const SingleGroupGenerator g = SingleGroupGenerator( 4 );
			Chord c = g.GenerateChord( sc::Note::A );
			AssertEqual( c.GetNoteCount(), 4 );
			AssertTrue( c.IsIncludeNote( sc::Note::A ) );
			AssertTrue( c.IsIncludeNote( sc::Note::C ) );
			AssertTrue( c.IsIncludeNote( sc::Note::EFlat) );
			AssertTrue( c.IsIncludeNote( sc::Note::FSharp ) );
		}
		{
			const SingleGroupGenerator g = SingleGroupGenerator( 4 );
			Chord c = g.GenerateChord( sc::Note::AFlat );
			AssertEqual( c.GetNoteCount(), 4 );
			AssertTrue( c.IsIncludeNote( sc::Note::AFlat ) );
			AssertTrue( c.IsIncludeNote( sc::Note::B ) );
			AssertTrue( c.IsIncludeNote( sc::Note::D ) );
			AssertTrue( c.IsIncludeNote( sc::Note::F ) );
		}
		{
			const SingleGroupGenerator g = SingleGroupGenerator( 3 );
			Chord c = g.GenerateChord( sc::Note::A );
			AssertEqual( c.GetNoteCount(), 3 );
			AssertTrue( c.IsIncludeNote( sc::Note::A ) );
			AssertTrue( c.IsIncludeNote( sc::Note::CSharp ) );
			AssertTrue( c.IsIncludeNote( sc::Note::F ) );
		}
		{
			const SingleGroupGenerator g = SingleGroupGenerator( 3 );
			Chord c = g.GenerateChord( sc::Note::AFlat );
			AssertEqual( c.GetNoteCount(), 3 );
			AssertTrue( c.IsIncludeNote( sc::Note::AFlat ) );
			AssertTrue( c.IsIncludeNote( sc::Note::C ) );
			AssertTrue( c.IsIncludeNote( sc::Note::E ) );
		}
		{
			const SingleGroupGenerator g = SingleGroupGenerator( 6 );
			Chord c = g.GenerateChord( sc::Note::A );
			AssertEqual( c.GetNoteCount(), 6 );
			AssertTrue( c.IsIncludeNote( sc::Note::A ) );
			AssertTrue( c.IsIncludeNote( sc::Note::B ) );
			AssertTrue( c.IsIncludeNote( sc::Note::CSharp ) );
			AssertTrue( c.IsIncludeNote( sc::Note::DSharp ) );
			AssertTrue( c.IsIncludeNote( sc::Note::F ) );
			AssertTrue( c.IsIncludeNote( sc::Note::G ) );
		}
		{
			const SingleGroupGenerator g = SingleGroupGenerator( 6 );
			Chord c = g.GenerateChord( sc::Note::AFlat );
			AssertEqual( c.GetNoteCount(), 6 );
			AssertTrue( c.IsIncludeNote( sc::Note::AFlat ) );
			AssertTrue( c.IsIncludeNote( sc::Note::BFlat ) );
			AssertTrue( c.IsIncludeNote( sc::Note::C ) );
			AssertTrue( c.IsIncludeNote( sc::Note::D ) );
			AssertTrue( c.IsIncludeNote( sc::Note::E ) );
			AssertTrue( c.IsIncludeNote( sc::Note::GFlat ) );
		}
		{
			const SingleGroupGenerator g = SingleGroupGenerator( 2 );
			Chord c = g.GenerateChord( sc::Note::A );
			AssertEqual( c.GetNoteCount(), 2 );
			AssertTrue( c.IsIncludeNote( sc::Note::A ) );
			AssertTrue( c.IsIncludeNote( sc::Note::EFlat ) );
		}
		{
			const SingleGroupGenerator g = SingleGroupGenerator( 2 );
			Chord c = g.GenerateChord( sc::Note::AFlat );
			AssertEqual( c.GetNoteCount(), 2 );
			AssertTrue( c.IsIncludeNote( sc::Note::AFlat ) );
			AssertTrue( c.IsIncludeNote( sc::Note::D ) );
		}
	}

	void SingleGroupGeneratorTester::Test_GetDegree()
	{
		SingleGroupGenerator g = SingleGroupGenerator( 4 );
		AssertEqual( g.GetDegree(), 4 );

		g = SingleGroupGenerator( 3 );
		AssertEqual( g.GetDegree(), 3 );

		g = SingleGroupGenerator( 2 );
		AssertEqual( g.GetDegree(), 2 );

		g = SingleGroupGenerator( 5 );
		AssertEqual( g.GetDegree(), 5 );

	}
}
